package com.connor.bank.Controller;

import com.connor.bank.Control;
import com.connor.bank.View;
import com.connor.bank.view.LoginView;
import com.connor.bank.view.UserChoiceView;
import javax.swing.JOptionPane;

public class MasterControl {

    private View view;

    public void actionWith(String userCommand, Control control, View previousView) {
        previousView.dispose();
        switch (userCommand) {
            case "LoginSuccess":
                if (control.getClass() == LoginControl.class) {
                    view = new UserChoiceView();
                }
                break;
            case "LoginFailed":
                if (control.getClass() == LoginControl.class) {
                    JOptionPane.showMessageDialog(null, "Login Failed");
                    view = new LoginView();
                }
                break;
            case "userChoiceError":
                if (control.getClass() == UserChoiceControl.class) {
                    JOptionPane.showMessageDialog(null, "Invalid command");
                    view = new UserChoiceView();
                }
                break;
            default:
                break;
        }
        view.setVisible(true);
    }
}
